//
//  WHIntroduceFishSpotCell.m
//  WHEasyBizLink
//
//  Created by ShengMeng on 9/26/25.
//

#import "WHIntroduceFishSpotCell.h"
#import "WHIntroduceFishSpotModel.h"
#import "UIView+Rounded.h"
#import "SDAutoLayout.h"
#import "myUILabel.h"

@interface WHIntroduceFishSpotCell ()

/** 图片  **/
@property(nonatomic,strong)UIImageView*micon;

/** 名称  **/
@property (nonatomic, weak)UILabel *nameLabel;

@property (nonatomic, weak)UILabel *contentLabel;


@property(nonatomic,strong)UIView*mbgView;

@end

@implementation WHIntroduceFishSpotCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        //1.创建控件
        [self createUIControls];
        //2.设置样式(布局)
        [self setUpUIControlsLayout];
    }
    return self;
}

-(void)createUIControls
{
    self.backgroundColor = [UIColor clearColor];
    _mbgView = [[UIView alloc] init];
    _mbgView.backgroundColor = [UIColor whiteColor];
    self.mbgView.userInteractionEnabled = YES;
    [self.contentView addSubview:self.mbgView];
   
    
    [_mbgView setViewRoundedShadowWithRad:10 byRoundingCorners:UIRectCornerAllCorners];
    
    _micon = [[UIImageView alloc] init];
    _micon.backgroundColor =whBlueColor;
    _micon.layer.cornerRadius = 2.0;
    [self.mbgView addSubview:self.micon];
    
   // [_micon setViewRoundedShadowWithRad:10 byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight];
    
    /**  应用名称  **/
    myUILabel*nameLabel = [[myUILabel alloc]init];
    nameLabel.font = [UIFont systemFontOfSize:18];
    //appNameLabel.textColor = [UIColor whiteColor];
    nameLabel.textColor = [UIColor colorWithHexString:@"#3C3C3C" alpha:1.0];
    nameLabel.numberOfLines = 2;
    [self.mbgView addSubview:nameLabel];
    nameLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
    _nameLabel = nameLabel;
    
  
    UILabel*contentLabel = [[UILabel alloc]init];
    contentLabel.font = [UIFont systemFontOfSize:14];
    contentLabel.textColor = [UIColor colorWithHexString:@"#767676" alpha:1.0];
    [self.mbgView addSubview:contentLabel];
    _contentLabel= contentLabel;
  
}

- (void)setUpUIControlsLayout
{
    _mbgView
    .sd_layout
    .topSpaceToView(self.contentView, 5)
    .bottomSpaceToView(self.contentView, 10)
    .leftSpaceToView(self.contentView, 20)
    .rightSpaceToView(self.contentView,20);
    
    _micon
    .sd_layout
    .topSpaceToView(self.mbgView,10)
    .leftSpaceToView(self.mbgView,10)
    .widthIs(5)
    .heightIs(20);
    
    _nameLabel
    .sd_layout
    .centerYEqualToView(_micon)
    .leftSpaceToView(self.micon,5)
    .widthIs(ScreenW*2/3)
    .heightIs(30);
    
    _contentLabel
    .sd_layout
    .topSpaceToView(self.nameLabel,10)
    .leftSpaceToView(self.micon,10)
    .rightSpaceToView(self.mbgView, 10)
    .autoHeightRatio(0);
    
    [self setupAutoHeightWithBottomViewsArray:@[self.contentLabel] bottomMargin:30];
    [_mbgView setupAutoHeightWithBottomViewsArray:@[self.contentLabel] bottomMargin:10];
    
}

-(void)setModel:(WHIntroduceFishSpotModel *)model
{
    _model = model;
    _nameLabel.text     = _model.titleName;
    _contentLabel.text  =_model.contents;
    
}

@end
